<template>
  	<div id="organizationQualificationCertificate">
  		<header>
  			<i @click="goBack()"></i>
  			<div>资质证书认证</div>
  		</header>
  		<div class="border-8"></div>
    	<div class="box">
    		<div>
    			<p>机构营业执照上传: 支持png,jpg,gif格式的图片</p>
	    		<el-upload
                  class="avatar-uploader"
                  :action='$api.baseURLUpload+"/photos/upload_shop"'
                  :show-file-list="false"
                  :on-success="handleAvatarSuccess"
                  :before-upload="beforeAvatarUpload">
                  <img v-if="imageUrl" :src="imageUrl" class="avatar">
                  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                </el-upload>
	    		<a href="javascript:;" @click='upload'>提交</a>
    		</div>
    	</div>
	</div>
</template>
<script>
	export default {
		data() {
			return {
				list: [],
                imageUrl: '',
			}
		},
		components: {

		},
		methods: {
			goBack() {
				this.$router.back();
			},
            //上传图片
            handleAvatarSuccess(res, file) {
                if(res.state == 200) {
                   this.imageUrl = res.result_origin;
                }
            },
            beforeAvatarUpload(file) {
                if(!/image\/\w+/.test(file.type)) {
                    this.$utils._toast('请确保文件为图像类型');
                    return false;
                }
                if(file.size > 5 * 1024 * 1024) {
                    this.$utils._toast('上传图片不能超过5M');
                    return false;
                }
            },
            //点上传按钮传到表中
            upload() {
                if(this.imageUrl) {
                    var params = [{
                        img_url: this.imageUrl,
                        content: '机构营业执照',
                    }];
                    localStorage.setItem("authpic", JSON.stringify(params));
                    this.$router.back();
                }
            },
            init() {
                var authpic = JSON.parse(localStorage.getItem("authpic"));
                if(authpic[0].content == '机构营业执照') {
                    this.imageUrl = authpic[0].img_url;
                }
            }
		},
		created() {
            this.init();
		},
		mounted() {
		}
	}
</script>
<style lang="scss">
</style>
